package com.example.demo.controller;


import com.example.demo.entity.db1.User;
import com.example.demo.service.UserService;
import com.example.demo.test.MySessionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/select/list")
    public List<User> selectUserList() {

        return this.userService.selectUserList();
    }

    @GetMapping("/save")
    public void saveUser(User user, HttpSession session) {

        String id = session.getId();
        session.setAttribute("name","cf");
        MySessionContext myc= MySessionContext.getInstance();
        HttpSession sess = myc.getSession(id);
        session.invalidate();

        //userService.saveUser(user);
    }


}